package cinema;
import cinema.model.Manager;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class CinemaShowTime {
    private List<Cinema> cinemaList = new ArrayList<>();
    Manager manager;
    public static class Cinema{
        String movieName;
        int duration;
        public Cinema(String movieName,int duration){
            this.duration=duration;
            this.movieName=movieName;
        }
        public String getMovieName(){
            return movieName;
        }
        public int getDuration() {
            return duration;
        }

        @Override
        public String toString() {
            return "Cinema{" +
                    "movieName='" + movieName + '\'' +
                    ", duration=" + duration +
                    '}';
        }

        public void setMovieName(String a) {
            this.movieName=a;
        }
    }
    public static class showTime{
        Cinema cinema;
        String theater;
        LocalDateTime time;
        public showTime(Cinema cinema,String theater,LocalDateTime time){
            this.cinema=cinema;
            this.theater=theater;
            this.time=time;
        }
        public Cinema getCinema(){
            return cinema;
        }

        public String getTheater() {
            return theater;
        }

        public LocalDateTime getTime() {
            return time;
        }


        @Override
        public String toString() {
            return "showTime{" +
                    "cinema=" + cinema +
                    ", theater='" + theater + '\'' +
                    ", time=" + time + '}';
        }
    }
    private List<showTime>showTimes=new ArrayList<>();
    public void addshowTimes(Cinema cinema,String theater,LocalDateTime time){
        showTimes.add(new showTime(cinema,theater,time));
    }
    public List<showTime> getShowTimesByMovie(String movieName) {
        List<showTime> result = new ArrayList<>();
        for (showTime st : showTimes) {
            if (st.getCinema().getMovieName().equalsIgnoreCase(movieName)) {
                result.add(st);
            }
        }
        return result;
    }

    // 打印某电影的所有场次
    public void printShowTimesForMovie(String movieName) {
        List<showTime> movieShowTimes = getShowTimesByMovie(movieName);

        if (movieShowTimes.isEmpty()) {
            System.out.println("没有找到《" + movieName + "》的放映场次");
            return;
        }

        System.out.println("《" + movieName + "》放映场次：");
        for (showTime st : movieShowTimes) {
            System.out.println(st);
        }
        System.out.println("共 " + movieShowTimes.size() + " 场放映");
    }

    public void modifyMovieName(String oldName, String newName) {

        System.out.println("修改成功！影片名从 [" + oldName + "] 改为 [" + newName + "]");
        return;
    }

}


